#include "OpenChestDialog.h"

OpenChestDialog::OpenChestDialog(void)
	:pOpenItem(NULL)
{
	
}


OpenChestDialog::~OpenChestDialog(void)
{
}

void OpenChestDialog::refresh()
{
	setIcon(1);
	setItemTip(1);
	//CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true);
}

bool OpenChestDialog::init()
{
	pBg = CCSprite::create("battle_result_bg.png");
	pBg->setPosition(cult(pBg, 0, 312));
	pBg->setScaleY(1.8);
	this->addChild(pBg);

	pIconBg = CCSprite::create("open_chest_icon_bg.png");
	pIconBg->setPosition(cult(pIconBg, 15, 20));
	this->addChild(pIconBg);

	pOpenTip = CCLabelTTF::create("打开宝箱，发现了", "Arial", 15);
	pOpenTip->setPosition(cult(pOpenTip, 5, 326));
	pOpenTip->setColor(ccc3(0, 255, 0));
	addChild(pOpenTip);

	return true;
}

void OpenChestDialog::setIcon( int itemID )
{
	if(pIcon != NULL)
		this->removeChild(pIcon, true);
	pIcon = CCSprite::create("item_02.png");
	pIcon->setPosition(cult(pIcon, 35, 25));
	pIcon->setScale(0.5);
	addChild(pIcon);
}

void OpenChestDialog::setItemTip(int itemID)
{
	if(pOpenItem == NULL)
	{
		pOpenItem = CCLabelTTF::create("aa", "Arial", 15);
		pOpenItem->setPosition(cult(pOpenItem, 60, 360));
		pOpenItem->setColor(ccc3(255, 0, 0));
		addChild(pOpenItem);
	}
	pOpenItem->setString("灵魂战甲");
}

void OpenChestDialog::touchScreen()
{
	close();
}
